--[[
    @desc: 
    author:{zcg}
    time:2019-07-29 24:15:46
    {paramdesc}
    @return:
]]
-- 元类
Shape = {area = 0}

-- 基础类方法 new
function Shape:new(o)
    o = o or {}
    setmetatable(o, self)
    self.__index = self
    return o
end

-- 基础类方法 printArea
function Shape:printArea()
    print("面积为 ", self.area)
end

Square = Shape:new()
function Square:new(o)
    o = o or Shape:new(o)
    setmetatable(o, self)
    self.__index = self
    return self
end

-- 派生类方法 printArea,重写
function Square:printArea()
    print("正方形面积为 ", self.area)
end

-- 创建对象
myshape = Shape:new()
myshape:printArea()

Square = Square:new()
Square.area = 100
Square:printArea()
myshape:printArea()
